Skip to content

feat: ai for ci diff action#42

Merged
yifancong merged 5 commits intomainfrom
feat/json-diff-ai
Apr 23, 2026
Merged

feat: ai for ci diff action#42
yifancong merged 5 commits intomainfrom
feat/json-diff-ai

Conversation

@yifancong
Copy link
Copy Markdown
Contributor

This pull request introduces an AI-powered degradation analysis feature to the Rsdoctor GitHub Action, enabling automated bundle size regression reports using Anthropic or OpenAI models. The main changes add a new input for selecting the AI model, implement logic to generate and analyze bundle diffs with AI, and update the PR comment to include the AI's findings.

AI analysis integration:

  • Added a new ai_model input to action.yml to allow users to specify which AI model to use for degradation analysis; the provider is auto-detected from the model name.
  • Implemented src/ai-analysis.ts, which detects the provider, builds prompts, and calls Anthropic or OpenAI APIs to analyze bundle diff JSONs and return concise markdown reports.
  • Updated src/index.ts to:
    • Import and use the new AI analysis module, and extend the ProjectReport type to include AI analysis results. [1] [2]
    • Pass aiToken and aiModel through the processing pipeline and generate bundle diff JSONs for AI analysis per project, handling both direct and npx-based CLI invocation. [1] [2] [3] [4]

PR comment/report enhancements:

  • Appended an expandable "AI Degradation Analysis" section to the PR comment, displaying per-project AI-generated analysis and the model used, when available.

Copilot AI review requested due to automatic review settings March 24, 2026 09:40
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 24, 2026

Rsdoctor Bundle Diff Analysis

Found 2 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
rsbuild-demo 190.4 KB -
rsbuild-demo2 190.3 KB -
📋 Detailed Reports (Click to expand)

📁 rsbuild-demo

Path: examples/rsbuild-demo/dist/.rsdoctor/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 190.4 KB - -
📄 JavaScript 188.5 KB - -
🎨 CSS 345.0 B - -
🌐 HTML 374.0 B - -
📁 Other Assets 1.2 KB - -

📁 rsbuild-demo2

Path: examples/rsbuild-demo2/dist/.rsdoctor/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 190.3 KB - -
📄 JavaScript 188.4 KB - -
🎨 CSS 345.0 B - -
🌐 HTML 374.0 B - -
📁 Other Assets 1.2 KB - -

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds AI-powered degradation analysis to the Rsdoctor GitHub Action by generating bundle-diff JSON and sending it to an LLM (Anthropic/OpenAI), then appending the results to the PR comment.

Changes:

  • Added ai_model action input and plumbed AI token/model through the processing pipeline.
  • Implemented src/ai-analysis.ts to build prompts, detect provider, and call Anthropic/OpenAI APIs.
  • Enhanced PR comment output with an expandable “AI Degradation Analysis” section per project.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/index.ts Runs JSON bundle-diff generation, calls AI analysis, and appends AI results into PR comments.
src/ai-analysis.ts New module to detect provider, build prompts, call LLM APIs, and return markdown analysis.
action.yml Adds the new ai_model input for selecting the model.
dist/index.js Compiled output updated to include AI analysis behavior.

Comment thread src/index.ts
Comment thread src/ai-analysis.ts Outdated
Comment thread src/ai-analysis.ts Outdated
Comment thread src/ai-analysis.ts
Comment thread src/index.ts
Comment thread action.yml
Comment thread src/index.ts
@gre
Copy link
Copy Markdown

gre commented Mar 26, 2026

That's a very interesting feature 👀 Do you plan to also make it ❌ on the PR? e.g. if some condition / based on some rules aren't satisfied (e.g; bundle size regression) could it make Github PR Status go fail?

@yifancong
Copy link
Copy Markdown
Contributor Author

That's a very interesting feature 👀 Do you plan to also make it ❌ on the PR? e.g. if some condition / based on some rules aren't satisfied (e.g; bundle size regression) could it make Github PR Status go fail?

@gre Before, I was afraid that it was not very stable at present, and I was afraid of misjudgment and interference, which would increase the threshold ability later.

@yifancong yifancong merged commit d7a4afc into main Apr 23, 2026
1 check passed
@yifancong yifancong deleted the feat/json-diff-ai branch April 23, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants